package net.lab1024.sa.admin.module.business.wms.warehouse.controller;


import net.lab1024.sa.admin.module.business.wms.domain.form.WarehouseQueryForm;
import net.lab1024.sa.admin.module.business.wms.domain.form.WarehouseUpdateForm;

import net.lab1024.sa.admin.module.business.wms.warehouse.domain.form.WarehouseAddForm;
import net.lab1024.sa.admin.module.business.wms.warehouse.domain.vo.WarehouseVO;
import net.lab1024.sa.admin.module.business.wms.warehouse.service.WarehouseService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * 仓库信息表 Controller
 *
 * @Author ADog
 * @Date 2025-10-17 17:25:29
 * @Copyright 1.0
 */

@RestController
@Tag(name = "仓库信息表")
public class WarehouseController {

    @Resource
    private WarehouseService warehouseService;

    @Operation(summary = "分页查询 @author ADog")
    @PostMapping("/warehouse/queryPage")
    @SaCheckPermission("warehouse:query")
    public ResponseDTO<PageResult<WarehouseVO>> queryPage(@RequestBody @Valid WarehouseQueryForm queryForm) {
        return ResponseDTO.ok(warehouseService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author ADog")
    @PostMapping("/warehouse/add")
    @SaCheckPermission("warehouse:add")
    public ResponseDTO<String> add(@RequestBody @Valid WarehouseAddForm addForm) {
        return warehouseService.add(addForm);
    }

    @Operation(summary = "更新 @author ADog")
    @PostMapping("/warehouse/update")
    @SaCheckPermission("warehouse:update")
    public ResponseDTO<String> update(@RequestBody @Valid WarehouseUpdateForm updateForm) {
        return warehouseService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author ADog")
    @PostMapping("/warehouse/batchDelete")
    @SaCheckPermission("warehouse:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return warehouseService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author ADog")
    @GetMapping("/warehouse/delete/{warehouseId}")
    @SaCheckPermission("warehouse:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long warehouseId) {
        return warehouseService.delete(warehouseId);
    }
}
